/*
 * PlanConstructorCall.java
 * 
 * Copyright 2004 Christoph Csallner and Yannis Smaragdakis.
 */
package edu.gatech.cc.cnc.plans.stmt;

import static edu.gatech.cc.jcrasher.Assertions.notNull;

import java.lang.reflect.Constructor;

import edu.gatech.cc.jcrasher.plans.expr.ConstructorCall;
import edu.gatech.cc.jcrasher.plans.stmt.Block;
import edu.gatech.cc.jcrasher.plans.stmt.BlockStatement;
import edu.gatech.cc.jcrasher.plans.stmt.LocalVariableDeclarationStatement;

/**
 * Sequence of statements terminated by a constructor call statement.
 * 
 * @param <T> type of value constructed by wrapped constructor.
 * 
 * @author csallner@gatech.edu (Christoph Csallner)
 */
 public class ConstructorCallingBlockStatementSequence<T> extends AbstractBlockStatementSequence<T> {
	
	
	/**
	 * Calling a static method on parameters created in plans.
	 * Supports CompundPlan in plans.
	 * 
	 * @returns block containing statements to call pMeth with curPlans.
	 */
	public ConstructorCallingBlockStatementSequence(
      Class<?> testeeType,
      BlockStatement<?>[] plans,
      Block enclosingBlock,
      Constructor<T> pCon)
  {
		super(
        enclosingBlock,
        enclosingBlock.getNextID(pCon.getDeclaringClass()),
        plans);
    
		notNull(plans);
    notNull(pCon);

		/* we need to create names for params to pass into constructor. */
		BlockStatement conStmt = new LocalVariableDeclarationStatement<T>(
        name, 
        new ConstructorCall<T>(testeeType, pCon, localNames));
    
		super.statements.add(conStmt);
	}
}
